<template>
  <div class="needshop">
       <input type="text" v-model="text" @keyup.13="sear()"><span @click="go()">取消</span>
        <ul>
          <li v-for="(item,index) in getshoplist">{{item}}</li>
        </ul>
        <div @click="clearshoplist()">清除记录</div>
  </div>
</template>

<script>
  import {mapMutations, mapState, mapGetters} from 'vuex' 
  export default {
     data(){
        return {
          text: "搜索你想要的商品"
        }
     },
     computed:{
        ...mapGetters([
            'getshoplist'
        ])

     },
     methods:{
        go: function() {
          this.$router.go(-1);
        },
        sear(){
            this.$store.dispatch('setshoplist',{
              text1:this.text
            });
           this.$http.jsonp('http://shopping-snxd.suning.com/cmwspds-web/cmmdty/searchCmmdty.do', {
            params: {
                retailFormatTypes:'0,1,2',
                orderBy:0,
                pageSize:10,
                pageNumber:1,
                source:"wap",
                version:3,
                _:1491903232153,
               storeCode:"910D",
               cityCode:1000173,
               keyword:this.text
            },
            jsonp: 'callback',
            jsonpCallback: 'jsonp1'
          }).then((rep) => {
              
          })
        },
        clearshoplist (){
            this.$store.dispatch('clearshoplist');
        }
     }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less">
 
  
</style>
